package com.zretc.controller;

import com.zretc.entity.Address;
import com.zretc.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/addressController")
public class AddressController {

    @Autowired
    private AddressService addressService;


    /**
     * 添加地址
     * @param address
     * @return
     */
    @RequestMapping("/insertAddress")
    @ResponseBody
    public boolean insertAddress(Address address) {

        int n = addressService.saveAddress(address);
        if (n > 0) {
            return true;
        }
        return false;
    }

    /**
     * 删除地址
     * @param addressId
     * @return
     */
    @RequestMapping("/deleteAddress")
    @ResponseBody
    public boolean deleteAddress(Integer addressId) {
        int n = addressService.deleteAddressbyAddressId(addressId);
        if (n > 0) {
            return true;
        }
        return false;
    }
}
